##############################################################
#Figure E2: Gtrends Result: Hurricane Proximity and Real Estate Agencies
##############################################################

library(tidyr)

df <- read.dta13("./temp/fige2data.dta")
newdf <- df %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(1,2,3,4)

ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=logd_coef, ymin=logd_ci_upper, 
                                          ymax=logd_ci_lower), color="black", size=1, lwd=1, fatten=2) +
  coord_flip() + 
  theme_bw() + 
  scale_x_discrete(limit=c("1", "2", "3", "4"), labels= c("Real Estate Agent", "Redfin", "Remax", "Zillow")) + 
  xlab("Keyword Searched")  + ylab("Estimate") +
  geom_hline(yintercept=0, col="grey60", lwd=1, lty="dashed") + 
  theme(panel.grid.major = element_blank(),
        axis.text = element_text(size=15), 
        axis.title = element_text(size=18))

ggsave("./figures/fige2.pdf")
